<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>ES Module 浏览器环境 Polyfill</title>
</head>
<body>
  <script>
  


    if (navigator.mediaDevices === undefined) {
     navigator.mediaDevices.getUserMedia = function (constraints) {
          var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
          if (!getUserMedia) {
              return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
          }
	        return new Promise(function (resolve, reject) {
	           		getUserMedia.call(navigator, constraints, resolve, reject);
	           });
          }
  
    }


    console.log(navigator.mediaDevices.getUserMedia)
      
    var promise = navigator.mediaDevices.getUserMedia({
                    audio: true,
                    video: {
                      width: { min: 1024, ideal: 1280, max: 1920 },
                      height: { min: 776, ideal: 720, max: 1080 }
                    }
                  });
    console.log(promise)

    // navigator.mediaDevices.getUserMedia(constraints)
    // .then(function(stream) {
    //   /* 使用这个stream stream */
    // })
    // .catch(function(err) {
    //   /* 处理error */
    // });
  </script>
</body>
</html>
